home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / InteractiveBook_Files / Examples / Chapter1 / Rattling / 2 recreate breadboard.nsm < prev    next >
Encoding:
Text File  |  2002-03-08  |  6.6 KB  |  176 lines

  1. //activeBreadboard. lockWindowUpdate()
  2. //
  3. // This macro creates the standard linear regression breadboard
  4. //
  5. subtitleTextBox. setText ("")
  6. mainTextBox. setText ("")
  7. //
  8. // drop down input axon and file icon
  9. //
  10. activeBreadboard. setAnimatePoint ( 20 , 225 )
  11. activeBreadboard. stampAndMove ( "Axon" , "inputAxon" )
  12. inputAxon. setRows ( 1 )
  13. activeBreadboard. stampOnAndMove ( "File" , "inputAxon" )
  14. file. setName ("inputFile")
  15. inputFile. setActiveAccessPoint ( "Pre-Activity" )
  16. inputFilePath = macro. pathFromMacro ( "regression input.asc" )
  17. inputFile. addFile ( inputFilePath , FALSE )
  18. inputFile. setActiveTranslatorName ( "ASCII - Column" , FALSE )
  19. inputFile. setNormalize ( FALSE )
  20. inputFile. translate (  )
  21. //
  22. // put down synapse and bias axon
  23. //
  24. activeBreadboard. setAnimatePoint ( 110 , 225 )
  25. activeBreadboard. stampAndMove ( "FullSynapse" , "hidden1Synapse" )
  26. inputAxon. connectTo ( "hidden1Synapse" )
  27. activeBreadboard. setAnimatePoint ( 200 , 225 )
  28. activeBreadboard. stampAndMove ( "Axon" , "outputAxon" )
  29. outputAxon. setRows ( 1 )
  30. hidden1Synapse. connectTo ( "outputAxon" )
  31. //
  32. // put down controller
  33. //
  34. activeBreadboard. setAnimatePoint ( 15 , 200 )
  35. activeBreadboard. stampAndMove ( "StaticControl" , "control" )
  36. control. setEpochs ( 1 )
  37. activeBreadboard. stampOnAndMove ( "DataStorage" , "inputAxon" )
  38. dataStorage. setName("inputActivityStorage")
  39. activeBreadboard. stampOnAndMove ( "ScatterPlot" , "inputActivityStorage" )
  40. scatterPlot. setName("inputActivityScatterPlot")
  41. activeBreadboard. stampOnAndMove ( "DataStorageTransmitter" , "outputAxon" )
  42. dataStorageTransmitter. setName("outputActivityTransmitter")
  43. outputActivityTransmitter. setActiveAccessPoint ( "Activity" )
  44. outputActivityTransmitter. toggleConnection ( "inputActivityStorage" , "attachToBuffer" )
  45. // 
  46. // add l2 and viewer
  47. //
  48. activeBreadboard. setAnimatePoint ( 310 , 225 )
  49. activeBreadboard. stampAndMove ( "L2Criterion" , "criterion" )
  50. outputAxon. connectTo ( "criterion" )
  51. activeBreadboard. stampOnAndMove ( "File" , "criterion" )
  52. file. setName(desiredFile)
  53. desiredFile. setActiveAccessPoint ( "Desired Signal" )
  54. desiredFilePath = macro. pathFromMacro ( "regression desired.asc" )
  55. desiredFile. addFile (desiredFilePath , FALSE )
  56. activeBreadboard. select ( "desiredFile" , FALSE )
  57. desiredFile. setNormalize ( FALSE )
  58. activeBreadboard. stampOnAndMove ( "DataStorageTransmitter" , "desiredFile" )
  59. dataStorageTransmitter. toggleConnection ( "inputActivityStorage" , "attachToBuffer" )
  60. //
  61. // add scatter plot
  62. //
  63. inputActivityStorage. setMessageEvery ( 12 )
  64. inputActivityStorage. setBufferLength ( 12 )
  65.  
  66. inputActivityScatterPlot. openEngineWindow (  )
  67. inputActivityScatterPlot. setXMaxScale (12.0000 )
  68. inputActivityScatterPlot. setXMinScale ( -1.0000 )
  69. inputActivityScatterPlot. setYMaxScale ( 10.000000 )
  70. inputActivityScatterPlot. setYMinScale ( -10.000000 )
  71. inputActivityScatterPlot. setBroadcast ( TRUE )
  72. inputActivityScatterPlot. setDotSize ( 3 )
  73. inputActivityScatterPlot. setBroadcast ( FALSE )
  74. inputActivityScatterPlot. setActiveChannel ( 2 )
  75. inputActivityScatterPlot. setVisible ( TRUE )
  76. inputActivityScatterPlot. setActiveChannel ( 1 )
  77. inputActivityScatterPlot. setVisible ( TRUE )
  78. inputActivityScatterPlot. setActiveChannel ( 0 )
  79. inputActivityScatterPlot. setVisible ( FALSE )
  80. inputActivityScatterPlot. setFixWindowTitle ( TRUE )
  81. inputActivityScatterPlot. setWindowTitle ( "Input Data (red) and Regression Line (blue)" )
  82. inputActivityScatterPlot. tileWindow(1,3,3,3)
  83. //
  84. activeBreadboard. stampOnAndMove ( "MatrixViewer" , "criterion" )
  85. matrixViewer. setName(costViewer)
  86. costViewer. setActiveAccessPoint ( "Average Cost" )
  87. costViewer. setEnableLabels ( TRUE )
  88. costViewer. setAccessRows(FALSE)
  89. costViewer. setLabel ( "Mean Squared Error" )
  90. costViewer. setAccessRows ( TRUE )
  91. costViewer. setLabel ( "" )
  92. costViewer. openEngineWindow (  )
  93. costViewer. tileWindow(4,4,5,6)
  94.  
  95. activeBreadboard. select ( NULL, FALSE )
  96.  
  97. //
  98. // add viewers
  99. //
  100. activeBreadboard. stampOnAndMove ( "MatrixViewer" , "hidden1Synapse" )
  101. matrixViewer. setName ( "weightViewer" )
  102. weightViewer. setActiveAccessPoint ( "Weights" )
  103. weightViewer. setEnableLabels ( TRUE )
  104. weightViewer. setLabel ( "w" )
  105. weightViewer. setAccessRows ( FALSE )
  106. weightViewer. setLabel ( "Weight" )
  107. weightViewer. openEngineWindow (  )
  108.  
  109. weightViewer. tileWindow(4,4,5,6)
  110. costViewer. tileWindow(4,4,6,6)
  111.  
  112. //
  113. // set initial conditions
  114. //
  115. hidden1Synapse. setWeightMean (1 )
  116. hidden1Synapse. setWeightVariance ( 0 )
  117. hidden1Synapse. networkRandomize (  )
  118. control. setEpochs ( 100 )
  119. control. resetNetwork (  )
  120. control. runNetwork (  )
  121. //
  122. // add backprop layer
  123. //
  124. activeBreadboard. stampOnAndMove ( "BackStaticControl" , "control" )
  125. activeBreadboard. select ( "controlBackprop" , FALSE )
  126. controlBackprop. allocateBackpropPlane (  )
  127. hidden1SynapseBackpropGradient. setStepSize ( 0.020000 )
  128.  
  129. //
  130. // add weight track
  131. //
  132. activeBreadboard. stampOnAndMove ( "DataStorage" , "weightViewer" )
  133. dataStorage. setName ( "weightStorage" )
  134. weightStorage. setMessageEvery ( 12 )
  135. weightStorage. setBufferLength ( 1210 )
  136. activeBreadboard. stampOnAndMove ( "MegaScope" , "weightStorage" )
  137. activeBreadboard. select ( "hidden1SynapseBackprop" , FALSE )
  138. activeBreadboard. moveToBack (  )
  139. activeBreadboard. select ( "megaScope" , FALSE )
  140. megaScope. setAmplitude ( 0.100000 )
  141. megaScope. setSweepRate ( 121.000000 )
  142. megaScope. setName ( "weightScope" )
  143. weightScope. setFixWindowTitle ( TRUE )
  144. weightScope. setWindowTitle ( "Weight Track" )
  145. weightScope. openEngineWindow (  )
  146. weightScope.tileWindow(2,3,3,3)
  147. weightScope. setVerticalPosVolts ( -0.490000 )
  148. //
  149. // add box to change learning rate
  150. //
  151. runPath = macro. pathFromMacro ( "..\make edit box.nsm" )
  152. activeBreadboard. runMacro ( runPath )
  153. activeBreadboard. moveSelectionBy ( 450 , 200 )
  154. newTextBox. setName("learnRateTextBox")
  155. newEditBox. setName("learnRateEditBox")
  156. learnRateTextBox. setText("Lrn Rate")
  157. learnRateEditBox. setText("0.02")
  158. learnRatePath=macro. pathFromMacro("change lr.nsm")
  159. learnRateEditBox. setMacroPath(learnRatePath)
  160. activeBreadboard. select(NULL, FALSE)
  161.  
  162. activeBreadboard. stampOnAndMove ( "ArrowEngine" , "weightScope" )
  163.  
  164. //
  165. // fill in text
  166. //
  167. TextBoxPath = macro. pathFromMacro("textbox1.txt")
  168. NextMacroPath = macro. pathFromMacro ( "3 show rattling.nsm" )
  169. nextButton. setMacroPath ( NextMacroPath )
  170. CancelMacroPath= macro.pathFromMacro("..\minimize.nsm")
  171. cancelButton. setMacroPath ( CancelMacroPath)
  172. TitleIndex = titleTextBox. setTextFromFile (TextBoxPath, TitleIndex)
  173. SubtitleIndex = subtitleTextBox. setTextFromFile (TextBoxPath, SubtitleIndex)
  174. MainIndex = mainTextBox. setTextFromFile (TextBoxPath, MainIndex)
  175. //activeBreadboard. unlockWindowUpdate()
  176.